home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.2 / IRIX 6.2 CD2.iso / dist / outbox.idb / usr / etc / webdist.z / webdist
Encoding:
Text File  |  1996-06-10  |  4.5 KB  |  169 lines

  1. #!/usr/sbin/perl
  2.  
  3. ## Copyright 1995, Silicon Graphics, Inc.
  4. ## All Rights Reserved.
  5. ##
  6. ## This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  7. ## the contents of this file may not be disclosed to third parties, copied or
  8. ## duplicated in any form, in whole or in part, without the prior written
  9. ## permission of Silicon Graphics, Inc.
  10. ##
  11. ## RESTRICTED RIGHTS LEGEND:
  12. ## Use, duplication or disclosure by the Government is subject to restrictions
  13. ## as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  14. ## and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  15. ## successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  16. ## rights reserved under the Copyright Laws of the United States.
  17.  
  18. #
  19. #    webdist
  20. #
  21. #    Generates a Web Software Distribution page for a Inst
  22. #    distribution directory.
  23. #
  24. #    Usage:
  25. #
  26. #        webdist distdir 
  27. #
  28. #        distdir    Distribution directory path
  29. #
  30.  
  31. $scriptpath = "/cgi-bin/webdist.install.cgi";
  32. chop($disthost = `hostname`);
  33. chop($disthost = `/usr/sbin/canonhost $disthost`);
  34.  
  35. #
  36. # Check argument count and input parameters.  
  37. #
  38.  
  39. if ($#ARGV != 0) {
  40.     print "Usage: $0 distdir\n";
  41.     exit 1;
  42. }
  43.  
  44. $distdir = @ARGV[0];
  45. if (!-r $distdir) {
  46.     print STDERR "Error: Cannot read from distribution directory $distdir!\n";
  47.     exit 1;
  48. }
  49. if (!-d $distdir) {
  50.     print STDERR "Error: $distdir is not a directory!\n";
  51.     exit 1;
  52. }
  53.  
  54.  
  55. #
  56. # Check the distribution directory for product files and product descriptions
  57. # and set up the following arrays:
  58. #
  59. #    idbfiles contains the paths for the idb files 
  60. #    prodfiles contains the paths to the product spec files.
  61. #    prodnames contains the product names
  62. #    proddescs contains the product descriptions
  63. #
  64.  
  65. @idbfiles = <$distdir/*.idb>;
  66.  
  67. foreach $i (@idbfiles) {
  68.  
  69.     # Figure out the product file name
  70.     chop($dirname = `dirname $i`);
  71.     chop($prodname = `basename $i .idb`);
  72.     $prodfile = $dirname . "/" . $prodname;
  73.  
  74.     @showprodout = `/usr/sbin/showprods -v -f $distdir $prodname 2>&1`;
  75.  
  76.     if ($? != 0) {
  77.     print STDERR 
  78.           "Warning: Error getting description for product file $prodfile:@showprodout\n";
  79.  
  80.     } elsif ($#showprodout < 1) {
  81.  
  82.     print STDERR 
  83.           "Warning: Could not get description for product file $prodfile\n";
  84.  
  85.     } elsif ($showprodout[1] =~ /^ERROR/) {
  86.           "Warning: Error getting description for product file $prodfile:@showprodout\n";
  87.     } else {
  88.  
  89.     # successfully ran showprod on the product file
  90.     # Save the product name and product file path
  91.  
  92.     push(@prodnames, $prodname);
  93.     push(@prodfiles, $prodfile);
  94.  
  95.     # Get the product description
  96.  
  97.     $descline = $showprodout[2];
  98.  
  99.     $where = index($descline, "\"") + 1;
  100.     $descline = substr($descline, $where);
  101.  
  102.     $where = index($descline, "\"");
  103.     $descline = substr($descline, 0, $where);
  104.  
  105.     push(@proddescs, $descline);
  106.     }
  107. }
  108.  
  109.  
  110. if ($#prodnames < 0) {
  111.     print STDERR "No products found at $distdir.\n";
  112.     exit 1;
  113. }
  114.  
  115.  
  116. # Write the HTML for the Web Installation Page
  117. #
  118.  
  119. print "<HTML>\n";
  120. print "<HEAD>\n";
  121. print "<TITLE>$disthost:$distdir</TITLE>\n";
  122. print "</HEAD>\n";
  123.  
  124. print "<BODY BACKGROUND=\"/webdist/images/background.jpeg\">\n";
  125. print "<P ALIGN=\"CENTER\">";
  126. print "<IMG SRC=\"/webdist/images/dist.gif\">";
  127. print "</P>";
  128.  
  129. print "<H3 ALIGN=\"CENTER\">$disthost:$distdir</H3>\n";
  130.  
  131. print "<P ALIGN=\"CENTER\">";
  132. print "<IMG SRC=\"/webdist/images/bar.gif\">";
  133. print "</P>";
  134.  
  135. print "<H2>Installation Instructions</H2>\n";
  136. print "Select the products you want to install and press \"Install Software\" to start the installation.\n";
  137. print "<FORM METHOD=\"POST\" ACTION=\"$scriptpath\">\n";
  138. print "<H2>Software Products</H2>\n";
  139. print "<UL>\n";
  140.  
  141. for ($i = 0; $i <= $#prodnames; $i++) {
  142.     $prodname = $prodnames[$i];
  143.     $proddesc = $proddescs[$i];
  144.     if ($proddesc eq "") {
  145.     $proddesc = $prodname;
  146.     }
  147.     print "<LI> <input type=\"checkbox\"  name =\"$prodname\"> $proddesc\n";
  148. }
  149.  
  150. print "</UL>\n";
  151. print "<H2>Installation Options</H2>\n";
  152. print "<UL>\n";
  153. print "<LI> <input type=\"radio\" name=\"options\" value=\"immediate\" checked> Start the installation immediately.\n";
  154. print "<LI> <input type=\"radio\" name=\"options\" value=\"delay\"> Let me look at my selections before installing.\n";
  155. print "</UL>\n";
  156. print "<input type=\"submit\" value=\"Install Software\">\n";
  157. print "<input type=\"reset\" value=\"Clear Selections\">\n";
  158. print "<input type=\"hidden\" name=\"products\" value=\"";
  159. foreach $i (@prodnames) {
  160.     print "$i ";
  161. }
  162. print "\">\n";
  163. print "<input type=\"hidden\" name=\"distdir\" value=\"$disthost:$distdir\">\n";
  164. print "</FORM>\n";
  165. print "</BODY>\n";
  166.  
  167. exit 0
  168.